package mobileMoney;

import java.io.Serializable;

public class Transaction implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	short type;
	double amount;
	String description;
	Client clientOrig;
	Client clientDest = null;
	int fraudster = 0;
	double newBalanceDest;
	double newBalanceOrig;
	long step;
	String profileOrig, profileDest;

	public int getFraudster() {
		return fraudster;
	}

	public void setFraudster(int fraudster) {
		this.fraudster = fraudster;
	}

	public long getStep() {
		return step;
	}

	public void setStep(long step) {
		this.step = step;
	}

	public Transaction() {
		this.type = 0;
		this.amount = 0;
		this.newBalanceDest = 0;
		this.newBalanceOrig = 0;
	}

	public Transaction(Long step, Client clientOrig, Client clientDest,
			short type, double amount, String description) {
		super();
		this.step = step;
		this.clientOrig = clientOrig;
		this.newBalanceOrig = clientOrig.balance;
		this.profileOrig = clientOrig.profile.toString();
		this.clientDest = clientDest;
		this.newBalanceDest = clientDest.balance;
		this.profileDest = clientDest.profile.toString();
		this.type = type;
		this.amount = amount;
		this.description = description;
	}

	public Transaction(Long step, Client clientOrig, short type, double amount,
			String description) {
		super();
		this.step = step;
		this.clientOrig = clientOrig;
		this.newBalanceOrig = clientOrig.balance;
		this.profileOrig = clientOrig.profile.toString();
		this.type = type;
		this.amount = amount;
		this.description = description;
	}

	public Transaction(Long step, Client clientOrig, Client clientDest,
			short type, double amount, String description, int fraudster) {
		super();
		this.step = step;
		this.clientOrig = clientOrig;
		this.newBalanceOrig = clientOrig.balance;
		this.profileOrig = clientOrig.profile.toString();
		this.clientDest = clientDest;
		this.newBalanceDest = clientDest.balance;
		this.profileDest = clientDest.profile.toString();
		this.type = type;
		this.amount = amount;
		this.description = description;
		this.fraudster = fraudster;
	}

	public Transaction(Long step, Client clientOrig, short type, double amount,
			String description, int fraudster) {
		super();
		this.step = step;
		this.clientOrig = clientOrig;
		this.newBalanceOrig = clientOrig.balance;
		this.profileOrig = clientOrig.profile.toString();
		this.type = type;
		this.amount = amount;
		this.description = description;
		this.fraudster = fraudster;
	}

	public short getType() {
		return type;
	}

	public void setType(short type) {
		this.type = type;
	}

	public double getAmount() {
		return amount;
	}

	public void setAmount(long amount) {
		this.amount = amount;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Client getClientOrig() {
		return clientOrig;
	}

	public void setClientOrig(Client clientOrig) {
		this.clientOrig = clientOrig;
	}

	public Client getClientDest() {
		return clientDest;
	}

	public void setClientDest(Client clientDest) {
		this.clientDest = clientDest;
	}

	public String toString() {
		String ps = null;
		ps = Long.toString(step) + " " + clientOrig + " Profile "
				+ profileOrig + " -" + Double.toString(amount)
				+ " new Balance " + Double.toString(newBalanceOrig);
		return ps;
	}

	public String getRecord() {
		String ps = null;
		ps = Long.toString(step) + ",'" + clientOrig + "','" + clientOrig.age + "','"
				+ profileOrig + "','" + clientOrig.getLocation()
				+ "'," + Short.toString(type) + "," + Double.toString(amount)
				+ "," + Double.toString(newBalanceOrig) + ",'";
		if (clientDest != null) {
			ps += clientDest + "','" + profileDest + "'," + "'"
					+ clientDest.getLocation() + "',"
					+ Double.toString(newBalanceDest) + ",";
		} else {
			ps += "null','null','null',0,";
		}
		ps += fraudster + "";
		return ps;
	}

}
